package com.chagee.channel.api.bo.lark;

import com.chagee.channel.api.enums.LarkFileTypeEnum;
import java.io.Serializable;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import lombok.Data;
import lombok.SneakyThrows;

/**
 * @author: chang.jiawei
 * @date: 2024/01/16
 */
@Data
@Valid
public class UploadFileUrlBO implements Serializable {

    private static final long serialVersionUID = -864461624726666717L;
    /**
     * 需要带后缀，e.g."食品生产许可证.jpg"
     */
    @NotBlank(message = "文件名称不能为空!")
    private String fileName;

    @NotNull(message = "文件类型不能为空!")
    private LarkFileTypeEnum fileType;

    /**
     * 文件地址.
     */
    @NotBlank(message = "文件地址不能为空!")
    private String url;

    /**
     * 转换
     * @param uploadFile
     * @return
     */
    @SneakyThrows
    public static UploadFileUrlBO transfer(UploadFileByUrlVO uploadFile) {
        UploadFileUrlBO uploadFileUrlBO = new UploadFileUrlBO();
        uploadFileUrlBO.setFileName(uploadFile.getFileName());
        uploadFileUrlBO.setFileType(uploadFile.getFileType());
        uploadFileUrlBO.setUrl(uploadFile.getUrl());
        return uploadFileUrlBO;
    }
}
